/**
 * @param {number} numRows
 * @return {number[][]}
 */
var generate = function (numRows) {
  if (numRows === 1) return [[1]]
  if (numRows === 2) return [[1], [1, 1]]
  let yhArr = [[1], [1, 1]]
  for (let i = 3; i <= numRows; i++) {
    let arr = new Array(i).fill(1)
    for (let j = 1; j < arr.length - 1; j++) {
      arr[j] = yhArr[i - 2][j - 1] + yhArr[i - 2][j]
    }
    yhArr.push(arr)
  }
  return yhArr
};
console.log(generate(10))